package com.kaishengit.dao;

import java.sql.ResultSet;
import java.sql.SQLException;



import com.kaishengit.entity.Tourguide;
import com.kaishengit.util.DBHelp;
import com.kaishengit.util.RowMapper;

public class TourguideDao {
	private DBHelp<Tourguide> db = new DBHelp<Tourguide>();
	public Tourguide findByName(String name){
		String sql = "SELECT id,name,tel FROM t_guide WHERE name=?";
		Tourguide t = db.executeForObject(sql, new GuideRowMapper(), name);
		return t;
	}
	public void insertSale(String name,String tel){
		String sql = "INSERT INTO t_guide (name,tel) VALUE(?,?)";
		db.executeUpdate(sql, name,tel);
	}
	public void insertSale(String name){
		String sql = "INSERT INTO t_guide (name) VALUE(?)";
		db.executeUpdate(sql, name);
	}
	public class GuideRowMapper implements RowMapper<Tourguide>{

		public Tourguide mapperRow(ResultSet rs) throws SQLException {
			Tourguide t = new Tourguide();
			t.setId(rs.getInt("id"));
			t.setName(rs.getString("name"));
			t.setTel(rs.getString("tel"));
			return t;
		}
		
	}
}
